<!DOCTYPE html>
<html lang="en" xmlns:th="https://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
    <div class="caotainer">
        <h1>The Goods page</h1>
        <form th:action="@{/goods/doFindGoods}" method="get">
            <input type="text" name="name">
            <input type="submit" class="btn btn-primary btn-sm" value="查询">
            <input type="button" class="btn btn-primary btn-sm" onclick="doLoadGoodsAddUI()" value="添加商品">
        </form>
        <table class="table">
            <thead>
                <tr>
                    <th>id</th>
                    <th>name</th>
                    <th>remark</th>
                    <th>createdTime</th>
                    <th>delete</th>
                    <th>remarks</th>
                </tr>
            </thead>
            <tbody>
                <tr th:each="g:${list}">
                    <td th:text="${g.id}">1</td>
                    <td th:text="${g.name}">A</td>
                    <td th:text="${g.remark}">A..</td>
                    <td th:text="${#dates.format(g.createdTime, 'yyyy/MM/dd HH:mm:ss')}">2020/12/30</td>
                    <td><button class="btn btn-danger btn-xs" th:onclick="doDeleteById([[${g.id}]])">delete</button>
                        <button class="btn btn-warning btn-xs" th:onclick="doFindById([[${g.id}]])">update</button>
                    </td>
<!--                    <th><button>add</button></th>-->
                </tr>
            </tbody>
        </table>
    </div>
    <script>
        var rootUrl="http://localhost"
        function  doLoadGoodsAddUI() {
            location.href=`${rootUrl}/goods/doGoodsAddUI`;
        }


        function doDeleteById(id) {
            console.log("===doDeleteById===")
            location.href=`${rootUrl}/goods/doDeleteById?id=${id}`;
        }

        function doFindById(id) {
            location.href=`${rootUrl}/goods/doFindById/${id}`;
        }

    </script>
</body>
</html>